﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Util;
using Util.Domains;
using Util.Domains.Auditing;

namespace IterationLife.FootballTeaching.Models {
    /// <summary>
    /// 球员位置
    /// </summary>
    [Description( "球员位置" )]
    public partial class PlayerPosition : AggregateRoot<PlayerPosition>,IDelete,IAudited {
        /// <summary>
        /// 初始化球员位置
        /// </summary>
        public PlayerPosition() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化球员位置
        /// </summary>
        /// <param name="id">球员位置标识</param>
        public PlayerPosition( Guid id ) : base( id ) {
        }

        /// <summary>
        /// 名称
        /// </summary>
        [Required(ErrorMessage = "名称不能为空")]
        [StringLength( 50, ErrorMessage = "名称输入过长，不能超过50位" )]
        public string Name { get; set; }
        /// <summary>
        /// 编码
        /// </summary>
        [StringLength( 50, ErrorMessage = "编码输入过长，不能超过50位" )]
        public string Code { get; set; }
        /// <summary>
        /// 启用
        /// </summary>
        [Required(ErrorMessage = "启用不能为空")]
        public bool Enabled { get; set; }
        /// <summary>
        /// 排序号
        /// </summary>
        public int? SortId { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public Guid? CreatorId { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 最后修改人
        /// </summary>
        public Guid? LastModifierId { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [Required(ErrorMessage = "是否删除不能为空")]
        public bool IsDeleted { get; set; }
        
        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "球员位置编号", Id );
            AddDescription( "名称", Name );
            AddDescription( "编码", Code );
            AddDescription( "启用", Enabled.Description() );
            AddDescription( "排序号", SortId );
            AddDescription( "创建时间", CreationTime );
            AddDescription( "创建人", CreatorId );
            AddDescription( "最后修改时间", LastModificationTime );
            AddDescription( "最后修改人", LastModifierId );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( PlayerPosition newEntity ) {
            AddChange( "Id", "球员位置编号", Id, newEntity.Id );            
            AddChange( "Name", "名称", Name, newEntity.Name );
            AddChange( "Code", "编码", Code, newEntity.Code );
            AddChange( "Enabled", "启用", Enabled, newEntity.Enabled );
            AddChange( "SortId", "排序号", SortId, newEntity.SortId );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
            AddChange( "CreatorId", "创建人", CreatorId, newEntity.CreatorId );
            AddChange( "LastModificationTime", "最后修改时间", LastModificationTime, newEntity.LastModificationTime );
            AddChange( "LastModifierId", "最后修改人", LastModifierId, newEntity.LastModifierId );
        }
    }
}